import {
  getFormatterPrice,
  computeRate
} from '@const/filter'
// 产品大类
export const PRODUCT_CATEGORY = {
  1: '高值',
  2: '低值',
  3: '试剂',
  4: '设备',
  5: '低值'
}
// 管理分类
export const PRODUCT_MANAGE_CATEGORY = {
  1: 'Ⅰ类',
  2: 'Ⅱ类',
  3: 'Ⅲ类'
}
// 注册地
export const PRODUCT_REGISTER_TYPE = {
  0: '国产',
  1: '港澳台',
  2: '进口'
}
export const saleOrderProductListColumns = [
  {
    prop: 'companyCode',
    label: '配送商产品编码',
    minWidth: 160
  },
  {
    prop: 'deliveryProductName',
    label: '配送商产品名称',
    minWidth: 160
  },
  {
    prop: 'spec',
    label: '规格型号',
    minWidth: 120,
    showTooltipWhenOverflow: true,
    formatter: row => `${row.spec && row.model ? `${row.spec} ${row.model}` : row.model || row.spec ? `${row.model || row.spec}` : ''}`
  },
  {
    prop: 'manufacturer',
    label: '生产厂家',
    minWidth: 120,
    showTooltipWhenOverflow: true
  },
  {
    prop: 'registrationNumber',
    label: '注册证号/备案证号',
    minWidth: 180,
    showTooltipWhenOverflow: true
  },
  {
    prop: 'manageType',
    label: '管理分类',
    minWidth: 120,
    formatter: row => PRODUCT_MANAGE_CATEGORY[row.manageType]
  },
  {
    prop: 'price',
    label: '单价',
    minWidth: 120,
    formatter: row => getFormatterPrice(row.price || 0)
  },
  {
    prop: 'purchaseNum',
    label: '订单数量',
    width: 160
  },
  {
    prop: 'unit',
    label: '计量单位',
    minWidth: 120
  },
  {
    prop: 'amount',
    label: '小计金额',
    minWidth: 120,
    showTooltipWhenOverflow: true,
    formatter: row => getFormatterPrice(computeRate(row.count, row.price) || 0)
  },

  {
    prop: 'registerArea',
    label: '注册地',
    minWidth: 120,
    formatter: row => PRODUCT_REGISTER_TYPE[row.registerArea]
  },
  {
    prop: 'bigType',
    label: '产品大类',
    minWidth: 120,
    formatter: row => PRODUCT_CATEGORY[row.bigType]
  },
  {
    minWidth: 160,
    prop: 'provincePlatCode',
    label: '省平台产品编码',
    showTooltipWhenOverflow: true
  },
  {
    minWidth: 160,
    prop: 'platCode',
    label: 'M平台产品编码',
    showTooltipWhenOverflow: true
  },
  {
    width: '60',
    prop: 'action',
    label: '操作',
    fixed: 'right'
  }
]
